package com.singfan.core.dao.database.impl;

import com.singfan.common.db.DaoBaseGeneric;
import com.singfan.common.db.DbContext;
import com.singfan.common.db.config.Table;
import com.singfan.core.dao.database.IShopHairAppointmentDetailDao;
import com.singfan.core.dao.database.model.ShopHairAppointmentDetail;
import org.springframework.stereotype.Repository;

/**
 *
 * Author: hansonghe
 * Date: 2015-08-19 12:12
 * Desc:
 */
@Repository
public class ShopHairAppointmentDetailDaoImpl extends DaoBaseGeneric<ShopHairAppointmentDetail> implements IShopHairAppointmentDetailDao {
    @Override
    protected String getTableName(Object hashKey) {
        return tableNameBase;
    }

    @Override
    protected String getDatabaseId(Object hashKey) {
        return "app_1";
    }

    @Override
    public void create(ShopHairAppointmentDetail shopHairAppointmentDetail) {
        insertWithAutoIncrement(null, shopHairAppointmentDetail);
    }

    @Override
    public ShopHairAppointmentDetail find(long orderId) {
        String sql = "SELECT * FROM " + getTableName(null) + " WHERE order_id=?";
        return selectOne(null, sql, orderId);
    }

    @Override
    public void delete(long orderId) {
        String sql = "DELETE FROM " + getTableName(null) + " WHERE order_id=?";
        execute(null, sql, orderId);
    }
}
